<?php


namespace api\web\controller;


use api\web\model\NoticeModel;
use cmf\controller\RestBaseController;
use think\facade\Db;

class NoticeController extends RestBaseController
{
    //院部新闻表
    public function index()
    {
        $page = input('page/d',1);
        $pageSize = input('page_size',10);

        $data = NoticeModel::field('id,title,image,abstract,create_time')
            ->order('id','desc')
            ->page($page,$pageSize)
            ->select();
        $this->success('院部新闻列表',$data);
    }
    //文章详情
    public function content()
    {
        $id = input('id/d');
        if (empty($id)){
            $this->error('无参数');
        }
        $data = NoticeModel::withoutField('list_order,delete_time')
            ->find($id);

        if (!$data){
            $this->error('未查询到新闻');
        }
        $data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($data['content']));

        $this->success('文章详情',$data);
    }
}